﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace WSU.ChekaParallel.TestTask
{
    static class TestRun
    {
        private static async void TestRunWithAction()
        {
            await Task.Run(() =>
                         {
                             Console.WriteLine("begin task, ......");
                             Thread.Sleep(3000);
                             Console.WriteLine("task completes");
                         });
            Console.WriteLine("!!! callback after task is invoked");
        }

        private static async void TestRunWithFunc()
        {
            var input = 88;
            var result = await Task.Run(() =>
            {
                Console.WriteLine("begin task, ......");
                Thread.Sleep(3000);
                return input * input;
            });
            Console.WriteLine("!!! callback with result={0}", result);
        }

        public static void TestMain()
        {
            // TestRunWithAction();
            TestRunWithFunc();

            Helper.Pause();
        }// TestMain
    }
}
